﻿$(document).ready(function () {

    //alert('document ready');

    function mycallback(data, textStatus, jqXHR) {
        alert('in my callback');
    }

    function getIt(url) {
        debugger;
        $.ajax({
            url: url,
            dataType: 'json',
            type: 'GET',
            contentType: 'application/json; charset=utf-8',
            async: false,
            jsonp: 'mycallback',
            complete: function (jqXHR, textStatus) {
                alert('complete');
            },
            success: function (data, textStatus, jqXHR) {
                alert('success');
            },
            error: function (jqXHR, textStatus, errorThrown) {
                alert('error');
            },

            //,
            crossDomain: true,
            isLocal: true

        });
    }

    $.helper = {
        getJSONP: function (url) {
            $.ajax({
                url: url,
                dataType: "jsonp",
                type: "GET",
                contentType: "application/json; charset=utf-8",
                //                success: function (data) {
                //                    //debugger;
                //                    alert(data);
                //                },
                //                error: function (jqXHR, textStatus, errorThrown) {
                //                    alert('error');
                //                },
                async: false,
                jsonpCallback: 'mycallback'
                //jsonp: true
            });
        }
    };

    (function () {
        getIt('http://localhost:51985/mlb/franchises/all');
        //$.helper.getJSONP("http://localhost:51985/mlb/franchises/all");

    } ());

});